#include <iostream>
#include "../common/httplib.h"
#include "ContactHandler.h"

#define SERVER_IP   "0.0.0.0"   // 监听所有网卡
#define SERVER_PORT 8123        // 服务端端口号

int main()
{
    std::cout << "---> 服务启动..." << std::endl;
    
    httplib::Server svr;

    // 注册路由：新增联系人
    svr.Post("/contacts/add",ContactHandler::handleAddContact);
    svr.Post("/contacts/del",ContactHandler::handleDelContact);
    svr.Post("/contacts/find-one",ContactHandler::handleFindOneContact);
    svr.Post("/contacts/find-all", ContactHandler::handleFindAllContacts);

    
    std::cout << "🚀 Server started at http://" << SERVER_IP << ":" << SERVER_PORT << std::endl;
    svr.listen(SERVER_IP, SERVER_PORT); 
    return 0;
}